home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Demos / A.D. Software / OOFGraph / Application Source / BarGraphWindow.cp next >
Text File  |  1996-06-15  |  3KB  |  111 lines

  1. // ===========================================================================
  2. //    BarGraphWindow.cp                
  3. // ===========================================================================
  4. //
  5.  
  6. #include "BarGraphWindow.h"
  7.  
  8. #include <LApplication.h>
  9. #include <LGrowZone.h>
  10. #include <LWindow.h>
  11. #include <UDrawingState.h>
  12. #include <UMemoryMgr.h>
  13. #include <URegistrar.h>
  14.  
  15. #include "oofDrawStyleSet.h"
  16.  
  17. #define WIND_Graph        201
  18. #define PANE_Plot        301
  19.  
  20. // ---------------------------------------------------------------------------
  21. //        • BarGraphWindow
  22. // ---------------------------------------------------------------------------
  23. //    Constructor
  24.  
  25. BarGraphWindow::BarGraphWindow(LCommander* inSuperCommander, dbView *theView, StringPtr theTitle,
  26.                                           unsigned long xAxisLength)
  27. {
  28.     // Make a window
  29.     mDisplayWindow = LWindow::CreateWindow(WIND_Graph, inSuperCommander);
  30.     
  31.     //let's find our WASTE pane..
  32.     CPlotPane *PlotView = (CPlotPane *) mDisplayWindow->FindPaneByID(PANE_Plot);
  33.     
  34.     Rect theFrame;
  35.     PlotView->CalcLocalFrameRect( theFrame );
  36.     
  37.     oofColor theColor(4474,3442,53247);
  38.     mDisplayWindow->FocusDraw();
  39.     
  40.     short fontNum;
  41.     ::GetFNum("\pPalatino",&fontNum); // Get my favourite font :)
  42.     if(fontNum==0)
  43.         ::TextFont(1);
  44.     else
  45.         ::TextFont(fontNum);    
  46.     
  47.     mBarGraphPtr = new oofBarGraph(theFrame,theColor,theView,theTitle,xAxisLength);
  48.     mBarGraphPtr->setDrawStyleSet(oofDrawStyleSetDefaultIteration());
  49.     
  50.     PlotView->SetGraph(mBarGraphPtr);
  51.  
  52.     mDisplayWindow->Show();
  53. }
  54.  
  55.  
  56. // ---------------------------------------------------------------------------
  57. //        • ~BarGraphWindow
  58. // ---------------------------------------------------------------------------
  59. //    Destructor
  60.  
  61. BarGraphWindow::~BarGraphWindow()
  62. {
  63.     delete mDisplayWindow;
  64. }
  65.  
  66.  
  67. //    Register the functions to create our custom Pane classes
  68. void
  69. BarGraphWindow::RegisterClass()
  70. {
  71.     URegistrar::RegisterClass(LWindow::class_ID,  (ClassCreatorFunc)LWindow::CreateWindowStream);
  72.     URegistrar::RegisterClass(CPlotPane::class_ID,(ClassCreatorFunc)CPlotPane::CreatePlotPaneStream);
  73.     URegistrar::RegisterClass(LPrintout::class_ID,     (ClassCreatorFunc)LPrintout::CreatePrintoutStream);
  74.     URegistrar::RegisterClass(LPlaceHolder::class_ID, (ClassCreatorFunc)LPlaceHolder::CreatePlaceHolderStream);
  75. }
  76.  
  77. //-- Printing Stuff--
  78.  
  79. #define    Prto_PictText    901        //    Printout for printing the scrolling view
  80. #define    place_PictText    911        //    Placeholder for the main body
  81.  
  82. void
  83. BarGraphWindow::DoPrinting()
  84. {
  85.     // set graph to mono
  86.     mBarGraphPtr->setStyleToMono();
  87.  
  88.     //    Read the Printout resource and find the place
  89.     //    holders for the scrolling view.
  90.  
  91.     LPrintout    *thePrintout = LPrintout::CreatePrintout(Prto_PictText);
  92.     LPlaceHolder *thePlace    = (LPlaceHolder*) thePrintout->FindPaneByID(place_PictText);
  93.  
  94.     //    Now find the view in this window 
  95.     //    and install it into its place holder.
  96.  
  97.     LView *theView    = (LView *) mDisplayWindow->FindPaneByID(PANE_Plot);
  98.     thePlace->InstallOccupant(theView, kAlignAbsoluteCenter);
  99.  
  100.         //    This is the function that starts the printing.
  101.  
  102.     thePrintout->DoPrintJob();
  103.  
  104.         //    The Printout's destructor takes care of setting the
  105.         //    views back to where they came from.
  106.  
  107.     delete thePrintout;
  108.  
  109.     mBarGraphPtr->setStyleToColor();
  110. }
  111.